package com.originalpoint.origin_server.service.Impl;


import com.originalpoint.origin_server.mapper.UserManageMapper;
import com.originalpoint.origin_server.pojo.User;
import com.originalpoint.origin_server.service.UserManageService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 *@作者:lhj
 *Service实现类
 *@Date:2023/07/02
 */
@Service
public class UserManageServiceImpl implements UserManageService {


    @Resource
    private UserManageMapper userdao;


    /**
     根据UserId查询
     */
    public Object selectByUserId(Integer userId){
        return userdao.selectByUserId(userId);
    }


    /**
     根据UserId更新
     */
    public Integer updateByUserId(User demo){
        return userdao.updateByUserId( demo);
    }



    /**
     根据UserId删除
     */
    public Integer deleteByUserId(Integer userId){
        return userdao.deleteByUserId(userId);
    }





    /**
     insert:(插入)
     */
    public Object insert(User demo){
        userdao.insert(demo);
        return demo;
    }



    /**
     insertOrUpdate(插入或更新(根据主键或唯一索引更新，主键和唯一索引不会改变))
     */
    public Integer insertOrUpdate(User demo){
        return userdao.insertOrUpdate(demo);
    }



    /**
     insertBath:(批量插入)
     */
    public Integer insertBatch(List<User> list){
        return userdao.insertBatch(list);
    }



    /**
     insertOrUpdateBatch:(批量插入或更新)
     */
    public Integer insertOrUpdateBatch(List<User> list){
        return userdao.insertOrUpdateBatch(list);
    }



    /**
     selectList:(根据参数查询集合)
     */
    public List<User> selectList(Map<String,Object> param){
        int start = Integer.parseInt(param.get("pageSize").toString()) * (Integer.parseInt(param.get("pageNum").toString()) - 1);
        param.put("pageNum",start);
        return userdao.selectList(param);
    }



    /**
     selectCount:(根据集合查询数量)
     */
    public Long selectCount(Map<String,Object> param){
        return userdao.selectCount(param);
    }



}